package com.newegg.datafeed.adserving.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.newegg.datafeed.adserving.domain.UserChannel;

@Mapper
public interface UserChannelMapper {

	@Select("SELECT channel,user FROM userchannel")
	List<UserChannel> getAll();
	
	@Insert("INSERT INTO userchannel(channel,user) VALUES (#{channel},#{user});")
    void insert(UserChannel userChannel);
	
	@Delete("DELETE FROM userchannel WHERE channel=#{channel} AND user=#{user}")
    void delete(@Param("channel")String channel, @Param("user")String user);

	@Select("SELECT channel FROM userchannel where user=#{user}")
	List<String> getByUser(@Param("user") String user);

	@Delete("DELETE FROM userchannel WHERE user=#{user}")
	void deleteByUser(@Param("user") String user);
}
